library(e1071)

setwd("D:/ClassificationR")

#membuat data training
data.training = as.data.frame(rbind(
                c("Sunny","Hot","High","False","No"),
                c("Sunny","Hot","High","True","No"),
                c("Overcast","Hot","High","False","Yes"),
                c("Rainy","Mild","High","False","Yes"),
                c("Rainy","Cool","Normal","False","Yes"),
                c("Rainy","Cool","Normal","True","No"),
                c("Overcast","Cool","Normal","True","Yes"),
                c("Sunny","Mild","High","False","No"),
                c("Sunny","Cool","Normal","False","Yes"),
                c("Rainy","Mild","Normal","False","Yes"),
                c("Sunny","Mild","Normal","True","Yes"),
                c("Overcast","Mild","High","True","Yes"),
                c("Overcast","Hot","Normal","False","Yes"),
                c("Rainy","Mild","High","True","No")
                ))

names(data.training)[1] = "OUTLOOK"
names(data.training)[2] = "TEMP"
names(data.training)[3] = "HUMIDITY"
names(data.training)[4] = "WINDY"
names(data.training)[5] = "PLAY"

#membuat data testing
data.test = as.data.frame(cbind(
                "Sunny","Cool","High","True"
                ))

names(data.test)[1] = "OUTLOOK"
names(data.test)[2] = "TEMP"
names(data.test)[3] = "HUMIDITY"
names(data.test)[4] = "WINDY"

#proses 2
#membuat model 
model = naiveBayes(PLAY~., data = data.training)
print(model)

#proses 3
#melakukan prediksi
predict_result = predict(model, data.test)
print(predict_result)
